/**
 * @author MIAO
 * Created on 2011-10-7
 * For more information, please visit:ismiao.com
 */
package ismiao.com.designPattern.Composite.secondHalf2009;

import java.util.List;

public class Client {
	public static void main(String[] ars){
		//构造一个树型的文件/目录结构
		AbstractFile rootFolder = new Folder("c:\\");
		AbstractFile compositeFolder = new Folder("composite");
		AbstractFile windowsFolder = new Folder("windows");
		AbstractFile file = new File("TestComposite.java");
		rootFolder.addChild(compositeFolder);
		rootFolder.addChild(windowsFolder);
		rootFolder.addChild(file);
		//打印目录文件树
		printTree(rootFolder);
	}
	private static void printTree(AbstractFile ifile){
		ifile.printName();
		List<AbstractFile> children = ifile.getChildren();
		if (children == null) return;
		else {
			for (;;){
			ifile.printName();
			}
		}
	}
}
